package com.xju.ikun.service.serviceImpl;

import com.xju.ikun.bean.SongBean;
import com.xju.ikun.bean.SongerBean;
import com.xju.ikun.bean.SongerlistBean;
import com.xju.ikun.bean.SonglistBean;
import com.xju.ikun.dao.SongerDao;
import com.xju.ikun.dao.SongerlistDao;
import com.xju.ikun.service.SongerService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class SongerServiceImpl implements SongerService {
    @Autowired
    private SongerDao songerDao;
    @Autowired
    private SongerlistDao songerlistDao;

    @Override
    public int insertSongerBean(SongerBean songerBean) {
        return songerDao.insertSongerBean(songerBean);
    }

    @Override
    public List<SongerBean> findAll() {
        return songerDao.findAll();
    }

    @Override
    public int updateByPrimaryKey(SongerBean songerBean) {
        return songerDao.updateByPrimaryKey(songerBean);
    }

    @Override
    public int deleteByPrimaryKey(int srid) {
        return songerDao.deleteByPrimaryKey(srid);
    }

    @Override
    public List<SongerBean> selectLikeOne(String name) {
        return songerDao.selectLikeOne(name);
    }

    @Override
    public List<SongerBean> findByUserid(int userid) {
        List<SongerlistBean> songerlistBeans = songerlistDao.findByUserid(userid);
        List<SongerBean> songerBeans = new ArrayList<SongerBean>();
        for (SongerlistBean m1 : songerlistBeans) {
            int a = m1.getSongerlist_songerid();
            SongerBean songerBean = songerDao.findBySongerid(a);
            songerBeans.add(songerBean);
        }
        return songerBeans;
    }
}
